﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Share;

public class SampleTriggerListener : ITriggerListener
{
    public string Name => "Trigger Listener";

    public Task TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)
    {
        Console.WriteLine($"From Trigger listener : TriggerComplete\n{triggerInstructionCode}");
        return Task.Delay(1000, cancellationToken);
    }

    public Task TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
    {
        Console.WriteLine($"From Trigger listener : Trigger Fired");
        return Task.Delay(1000, cancellationToken);
    }

    public Task TriggerMisfired(ITrigger trigger, CancellationToken cancellationToken = default)
    {
        Console.WriteLine($"From Trigger listener : Trigger Misfired");
        return Task.Delay(1000, cancellationToken);
    }

    public Task<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
    {
        Console.WriteLine($"From Trigger listener : Trigger Veto Job");
        return Task.FromResult(false);
    }
}
